package com.surfacing.rcp.model.codec;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;


import org.apache.log4j.Logger;

import com.surfacing.rcp.model.common.AbstractMessage;
import com.surfacing.rcp.model.entity.Einsatzart;

public class EinsatzartEncoder implements MessageEncoder {
	private static final Logger log = Logger.getLogger(EinsatzartEncoder.class);

	@Override
	public void doEncode(AbstractMessage message, XMLStreamWriter writer)
			throws XMLStreamException {
		// Cast the object to a item
		Einsatzart member = (Einsatzart) message;

		// assert valid
		if (member == null) {
			log.warn("WARNING: Object einsatzart is null and cannot be encoded");
			return;
		}

		// start
		writer.writeStartElement(Einsatzart.ID);

		// write the elements and attributes
		writer.writeStartElement("einsatzartId");
		writer.writeCharacters(String.valueOf(member.getId()));
		writer.writeEndElement();
		// get the encoder for the location
		// write the elements and attributes
		writer.writeStartElement("ea");
		writer.writeCharacters(member.getEinsatzart());
		writer.writeEndElement();
		// write the elements and attributes
		// end
		writer.writeEndElement();
	}

}
